package com.zj.study.utils.beancopier.utils;

import org.springframework.asm.Type;

/**
 * @author 赵赳
 * @since 2021/9/22 11:51
 */
public class ClassInfo {
  private final Class<?> type;
  private final Class<?>[] genericTypes;

  public static ClassInfo of(Class<?> type, Class<?>... genericTypes) {
    return new ClassInfo(type, genericTypes);
  }

  public final String getDescriptors() {
    if (this.genericTypes != null && this.genericTypes.length != 0) {
      StringBuilder builder = (new StringBuilder(Type.getDescriptor(this.type))).append("<");
      Class[] var2 = this.genericTypes;
      int var3 = var2.length;

      for(int var4 = 0; var4 < var3; ++var4) {
        Class<?> g = var2[var4];
        builder.append(Type.getDescriptor(g));
      }

      builder.append(">");
      return builder.toString();
    } else {
      return Type.getDescriptor(this.type);
    }
  }

  public Class<?> getType() {
    return this.type;
  }

  public Class<?>[] getGenericTypes() {
    return this.genericTypes;
  }

  private ClassInfo(Class<?> type, Class<?>[] genericTypes) {
    this.type = type;
    this.genericTypes = genericTypes;
  }
}
